const STORAGE_KEY = 'farm_game_data'

export function saveGameData(data) {
  try {
    uni.setStorageSync(STORAGE_KEY, JSON.stringify(data))
    return true
  } catch (e) {
    console.error('保存游戏数据失败:', e)
    return false
  }
}

export function loadGameData() {
  try {
    const data = uni.getStorageSync(STORAGE_KEY)
    return data ? JSON.parse(data) : null
  } catch (e) {
    console.error('加载游戏数据失败:', e)
    return null
  }
}

export function clearGameData() {
  try {
    uni.removeStorageSync(STORAGE_KEY)
    return true
  } catch (e) {
    console.error('清除游戏数据失败:', e)
    return false
  }
} 